package com.example.pt.mapper;

import com.example.pt.entity.TorrentPromotion;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper // MyBatis Mapper 注解
public interface TorrentPromotionMapper {

    @Select("SELECT tp.* " +
            "FROM torrent_promotion tp " +
            "JOIN torrent_info_hash tih ON tp.tid = tih.tid " +
            "WHERE tih.info_hash = #{infoHash} " +  // MyBatis 参数占位符使用 #{...}
            "AND tp.start_time <= NOW() " +
            "AND tp.end_time > NOW()")
    List<TorrentPromotion> getCurrentPromotionsByInfoHash(@Param("infoHash") String infoHash);
}